package com.tianma315.admin.produce.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.tianma315.admin.common.base.CoreServiceImpl;
import com.tianma315.admin.produce.VO.ScBatchingVO;
import com.tianma315.admin.produce.domain.ScAdditiveDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tianma315.admin.produce.dao.ScBatchingDao;
import com.tianma315.admin.produce.domain.ScBatchingDO;
import com.tianma315.admin.produce.service.ScBatchingService;

import java.util.List;

/**
 * 
 * <pre>
 * 配料(生产)
 * </pre>
 * <small> 2019-05-30 09:53:17 | Aron</small>
 */
@Service
public class ScBatchingServiceImpl extends CoreServiceImpl<ScBatchingDao, ScBatchingDO> implements ScBatchingService {

    @Autowired
    private ScBatchingDao scBatchingDao;
    @Override
    public Page<ScBatchingVO> getScBatchingVO(Integer pageNumber, Integer pageSize, ScBatchingDO scBatchingDO) {
        Page<ScBatchingVO> page = new Page<>(pageNumber,pageSize);
        page.setRecords(scBatchingDao.getScBatchingPage(scBatchingDO.getProduceTaskId()));
        return page;
    }

    @Override
    public Boolean addScBatchingVO(ScBatchingDO scBatchingDO) {
        scBatchingDO.setState(0);
        return insert(scBatchingDO);
    }

    @Override
    public Boolean deleteScBatchingVO(Integer id) {
        ScBatchingDO scBatchingDO = new ScBatchingDO();
        scBatchingDO.setBatchingId(id);
        scBatchingDO.setState(1);
        return updateById(scBatchingDO);
    }

    @Override
    public List<ScBatchingDO> getScBatchingDO(Integer produceTaskId) {
        Wrapper<ScBatchingDO> wrapper = new EntityWrapper<>();
        wrapper.eq("state",0);
        wrapper.eq("produce_task_id",produceTaskId);
        List<ScBatchingDO> scBatchingDOList = selectList(wrapper);
        return scBatchingDOList;
    }
}
